﻿Public Class ViewDocument

    Private Sub Viewer_DataContextChanged(ByVal sender As Object, ByVal e As System.Windows.DependencyPropertyChangedEventArgs) Handles Viewer.DataContextChanged
        Dim newValue As ViewModelDocument = TryCast(e.NewValue, ViewModelDocument)
        If (Not newValue Is Nothing) Then
            Me.Viewer.Document = newValue.Document
            Me.Viewer.GoToPage(newValue.PageNumber)
            Me.Viewer.FitToWidth()
        End If

    End Sub
End Class
